\name{pcfcross3D}
\alias{pcfcross3D}
\title{Multitype Pair Correlation Function (Cross-type) for 3D Point Patterns}
\description{
  Calculates an estimate of the cross-type pair correlation function
  for a multitype three-dimensional point pattern.
}
\usage{
  pcfcross3D(X, i, j, \dots, 
           rmax = NULL, nrval = 128,
           correction = c("translation", "isotropic"),
           delta = NULL, adjust = 1, biascorrect = TRUE,
           ratio = FALSE)
}
\arguments{
  \item{X}{The observed 3D point pattern, 
    from which an estimate of the cross-type pair correlation function
    \eqn{g_{ij}(r)}{g[i,j](r)} will be computed.
    It must be a multitype point pattern (a marked point pattern
    whose marks are a factor) of class \code{pp3}.
  }
  \item{i}{The type (mark value)
    of the points in \code{X} from which distances are measured.
    A character string (or something that will be converted to a
    character string).
    Defaults to the first level of \code{marks(X)}.
  }
  \item{j}{The type (mark value)
    of the points in \code{X} to which distances are measured.
    A character string (or something that will be
    converted to a character string).
    Defaults to the second level of \code{marks(X)}.
  }
  \item{\dots}{
    Ignored.
  }
  \item{rmax}{
    Maximum value of argument \eqn{r} for which \eqn{g(r)} 
    will be estimated. 
  }
  \item{nrval}{
    Number of values of \eqn{r} at which \eqn{g(r)} will be estimated.
  }
  \item{correction}{
    A character vector specifying the edge correction(s) to be applied.
    Options are \code{"translation"} and \code{"isotropic"}.
  }
  \item{delta}{
    Bandwidth for the kernel estimator of the pair correlation function.
  }
  \item{adjust}{
    Adjustment factor for the default bandwidth.
  }
  \item{biascorrect}{
    Logical value indicating whether to apply bias correction.
  }
  \item{ratio}{
    Logical value indicating whether to return the numerator and denominator
    of the ratio estimate.
  }
}
\value{
  A function value table (object of class \code{"fv"})
  representing the estimated pair correlation function.
}
\details{
  This function computes an estimate of the cross-type pair correlation function
  \eqn{g_{ij}(r)}{g[i,j](r)} for a multitype three-dimensional point pattern.
  The pair correlation function describes the dependence between points
  of different types as a function of distance \eqn{r}.
  
  The function requires the point pattern to be a multitype pattern
  (marks must be a factor with at least two levels).
  
  Edge corrections are available: translation correction and isotropic correction.
  The default bandwidth is determined using the method of Stoyan and Stoyan (1995).
}
\seealso{
  \code{\link{pcf3est}} for the pair correlation function of unmarked 3D patterns,
  \code{\link{pcfcross}} for the 2D version of this function,
  \code{\link{pp3multitype}} for creating multitype 3D point patterns,
  \code{\link{is.multitype.pp3}} for checking if a pattern is multitype.
}
\examples{
  \dontrun{
  # Create a 3D multitype point pattern
  if(require(spatstat.geom)) {
    box <- box3(xrange=c(0,1), yrange=c(0,1), zrange=c(0,1))
    coords <- matrix(runif(300), ncol=3)
    marks <- factor(sample(c("A", "B"), 100, replace=TRUE))
    X <- pp3(x=coords[,1], y=coords[,2], z=coords[,3], domain=box, marks=marks)
    
    # Compute cross-type pair correlation function
    gAB <- pcfcross3D(X, "A", "B")
    plot(gAB)
  }
  }
}
\author{
  Adapted from original code by Adrian Baddeley, Rolf Turner and Ege Rubak.
}